package com.geeklan.smart.ui.viewmodel.user;

import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.geeklan.smart.data.repository.user.AccountRepository;

public class UserViewModelFactory implements ViewModelProvider.Factory {

    private final AccountRepository accountRepository;

    public UserViewModelFactory(AccountRepository userRepository) {
        this.accountRepository = userRepository;
    }

    @Override
    public <T extends ViewModel> T create(Class<T> modelClass) {
        if (modelClass.isAssignableFrom(UserViewModel.class)) {
            return (T) new UserViewModel(accountRepository);
        }
        throw new IllegalArgumentException("Unknown ViewModel class");
    }
}

